package co.edu.unal.geditor.view.tools;

import java.awt.Point;

import co.edu.unal.geditor.controller.action.tool.CircleToolAction;
import co.edu.unal.geditor.model.BoundBox;
import co.edu.unal.geditor.model.EllipseElement;
import co.edu.unal.geditor.model.GraphElement;

public class CircleCreationTool extends EllipseCreationTool {
	// v0.6 : CircleCreationTool provides its own Factory class
	private static class Factory extends ToolFactory {
		protected Tool create() {
			return new CircleCreationTool();
		}
	}

	// this block executed when the class object is loaded in the VM
	// registers its Factory
	static {
		ToolFactory.register(CircleCreationTool.class.getName(), new Factory());
	}

	public GraphElement createObject(Point ptPressed, Point ptReleased) {
		BoundBox bb = new BoundBox(ptPressed, ptReleased);

		bb.goSquare(); // normalized

		return super.createObject(bb.getLeftUp(), bb.getRightDown());
	}

	@Override
	protected void initAction() {
		setAction(new CircleToolAction());
		if(feedbackGraphElemet==null)
		{
		feedbackGraphElemet = new EllipseElement(new Point(0,0), new Point(20,20));
		}
	}

	
}
